programming4us
           
 
 
Windows

Windows Azure : Programming Access Control Service (part 10) - Deploying the Web Service in Windows Azure

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019
12/4/2010 11:55:53 AM

3. Deploying the Web Service in Windows Azure

Once you have tested the claims-based authentication and authorization for the ACSMachineInfo web service, you can package and deploy the web service as a Windows Azure cloud service. The steps required for packaging and deploying the ACSMachineInfo web service as a Windows Azure cloud service are as follows:

  1. Create a new Windows Azure cloud service project

  2. Create a new Worker Role with external endpoint in the cloud service

  3. Add the code from ACSMachineInfo to the Worker Role

  4. Test ACSMachineInfo web service in Development Fabric

  5. Deploy ACSMachineInfo web service in Windows Azure cloud

  6. Test ACSMachineInfo web service in Windows Azure cloud

Figure 14 shows the project structure for the cloud service and the worker role projects.

Figure 14. Cloud Service Project Structure

The ACSCloudService project is a Windows Azure cloud service project and the ACSMachineInfoWorker is the worker role that contains the implementation of the service. The movement of the service from regular WCF to a worker role cloud service should have minimal impact on the client because the web service Url remains the same.

Because the worker role does not have a default external (or input) endpoint, you need to create an external http endpoint for the worker role on port 80, so that all the http requests to the web service Url are received by the web service. Figure 15 shows the configuration setting for the external endpoint on port 80.

Figure 15. External Endpoint on port 80

The external endpoint configuration makes port 80 available to the web service for exposing external interface. The web service still needs to create a service on that port. Listing 15 shows the code for the Run() method in the worker role. The ACSMachineInfo web service is initialized on port 80 of the cloud service in this method.

Example 15. Worker Role Run method
const string serviceNamespace = "proazure-1";
const string trustedTokenPolicyKey = "8O++r46Eo6e6VhGQaHSCfINhYMMCu14xsAectW2EFfk=";

const string acsHostName = "accesscontrol.windows.net";
const string trustedAudience = "http://localhost/acsexample";
const string requiredClaimType = "action";

public override void Run()
{

WebHttpBinding binding = new WebHttpBinding
(WebHttpSecurityMode.None);

Uri address = new Uri(trustedAudience);

WebServiceHost host =
new WebServiceHost(typeof(ACSExample));
host.AddServiceEndpoint(typeof(IACSExample),
binding, address);

host.Authorization.ServiceAuthorizationManager =
new ACSAuthorizationManager(
acsHostName,
serviceNamespace,
trustedAudience,
Convert.FromBase64String(trustedTokenPolicyKey),


requiredClaimType);

try
{
host.Open();
while (true)
{
Thread.Sleep(10000);
}
}
finally
{
host.Close();

}
}

The code for initializing the web service is tan exact replica of the code from the WCF service that we deployed earlier in the article. Observer the Url for the web service does not change and because external endpoint is available on port 80, the service will be available publicly for consumption, provided the client gets authenticated by ACS.

To test the cloud web service in development fabric, select ACSCloudService and press F5 to run the web service in debug mode. Figure 16 shows the ACSMachineInfo web service running as worker role in development fabric.

Figure 16. ACSMachineInfo Web Service as Worker Role

Next, to test the client access, you can either run the client that generates SWT or client that acquires SAML token from a local STS. Figure 17 shows the command line output from the client that generates SWT locally and then calls ACS for authentication before calling the web service.

Figure 17. Web Service Client calling cloud web service with ACS authentication

Creating Your Own Certificates

In a claims-based identity model, X.509 certificates are used by all the participating parties: STS, ACS, and the relying party. X.509 certificates are used to encrypt and/or decrypt SAML tokens and also to validate claims sent from one party to another. Most of the examples in MSDN and training kits use a predefined set of certificates that can cause conflicts when used by multiple developers and testers in the same environment. The following are the steps you can use to create your own certificates so you don't have to rely on the prepackaged certificates in sample applications:

  1. Start the Visual Studio command prompt as an administrator.

  2. Run the following command to create a temporary certificate:

    makecert -n "CN=ProAzure" -r -sky exchange -sv ProAzure.pvk ProAzure.cer

  3. Run the following command to create a certificate that is digitally signed and authorized by ProAzure:

    makecert -sk ProAzureSignedCA -sky exchange -iv ProAzure
    .pvk -n "CN=ProAzureSignedCA" -ic ProAzure.cer ProAzureSignedCA.cer
    -sr localmachine -ss My

  4. Use MMC to Import the ProAzure.cer certificate into the Trusted Root Certificate Authorities folder of the local machine certificate store. You can start MMC from Start Run mmc.exe. Then, choose File Add/Remove Snap-In Certificates.

  5. From MMC, import ProAzureSignedCA.cer into the certificates personal folder of the local machine certificate store.

  6. Export the certificate to distribute it to the outside world, using the pvk2pfx.exe tool from the Visual Studio .NET\Tools\bin folder:

    pvk2pfx.exe -pvk ProAzure.pvk -spc ProAzure.cer

  7. If you're hosting your service in IIS and would like to give permissions to certificates to specific accounts, see the WinHttpCertCfg.exe certificate configuration tool at http://msdn.microsoft.com/en-us/library/aa384088(VS.85).aspx.


After the certificate is created, you can use it in any application that requires X.509 certificates. You can also share the same certificate across multiple applications.

The AppFabric ACS doesn't support WS-Trust and WS-Federation. As you saw from the examples, the protocol is REST-based and so can be easily used from multiple platforms. The core functionality of ACS is to map input claims to output claims by abstracting multiple input claims from multiple sources to a consistent set of output claims expected by the relying party. The relying party doesn't have knowledge of the input claim source; it trusts the output claims issued by ACS. The ACS management service API provides functions to create these mappings.

Other -----------------
- Windows 7 : Working with Registry Entries (part 3)
- Windows 7 : Working with Registry Entries (part 2)
- Windows 7 : Working with Registry Entries (part 1) - Changing the Value of a Registry Entry
- Windows 7 : Keeping the Registry Safe
- Windows 7 : Getting to Know the Registry (part 2)
- Windows 7 : Getting to Know the Registry (part 1) - Understanding Registry Settings
- Windows 7 : Firing Up the Registry Editor
- Windows Azure : Managing Access Control Service Resources (part 2)
- Windows Azure : Managing Access Control Service Resources (part 1)
- Windows Azure : Access Control Service Management Portal
- Windows 7 : Reset a Broken Service
- Windows 7 : Make Windows Shut Down Services Faster
- Windows 7 : Disable Services for Faster Performance
- Windows 7 : Controlling Services with a Script
- Windows 7 : Controlling Services at the Command Prompt
- Windows 7 : Controlling Services with the Services Snap-In
- Windows Azure : Access Control Service Usage Scenarios (part 3)
- Windows Azure : Access Control Service Usage Scenarios (part 2)
- Windows Azure : Access Control Service Usage Scenarios (part 1)
- Windows Azure : Access Control Service - Claims-Based Identity Model
 
 
 
Top 10
 
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 2) - Wireframes,Legends
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Finding containers and lists in Visio (part 1) - Swimlanes
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Formatting and sizing lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Adding shapes to lists
- Microsoft Visio 2013 : Adding Structure to Your Diagrams - Sizing containers
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 3) - The Other Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 2) - The Data Properties of a Control
- Microsoft Access 2010 : Control Properties and Why to Use Them (part 1) - The Format Properties of a Control
- Microsoft Access 2010 : Form Properties and Why Should You Use Them - Working with the Properties Window
- Microsoft Visio 2013 : Using the Organization Chart Wizard with new data
- First look: Apple Watch

- 3 Tips for Maintaining Your Cell Phone Battery (part 1)

- 3 Tips for Maintaining Your Cell Phone Battery (part 2)
programming4us programming4us